<template>
	
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				current: 0,
				price:'',
				type:'wx',
				img:'',
				uprice:''
			};
		},
		
		onLoad(e) {
			this.price = e.price
			this.uprice = e.price
		},
		
		methods: {
			 radioChange: function(evt) {
				this.type = evt.detail.value
				console.log(evt.detail.value)
			},
			upImg(){
				var that = this
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function (res) {
						let img = res.tempFilePaths;
						console.log(img[0])
						// 上传
						that.$http.upload('upImg', {
							filePath: img[0], // 要上传文件资源的路径。
							// 注：如果局部custom与全局custom有同名属性，则后面的属性会覆盖前面的属性，相当于Object.assign(全局，局部)
							custom: {
								auth: true
							}, // 可以加一些自定义参数，在拦截器等地方使用。比如这里我加了一个auth，可在拦截器里拿到，如果true就传token
							name: 'img', // 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容
							// 返回当前请求的task, options。请勿在此处修改options。非必填
						}).then(res => {
							// 返回的res.data 已经进行JSON.parse
							console.log(res)
							that.img = res.data.data
						}).catch(err => {
							console.log(err)
						})
					}
				});
			},
			apply(){
				let that = this
				if (parseFloat(this.price) > parseFloat(this.uprice)) {
					console.log(this.price , this.uprice)
					return uni.showToast({
						icon:'none',
						title:'余额不足'
					})
				}
				if (!that.img) {
					return uni.showToast({
						icon:'none',
						title:'请上传收款码'
					})
				}
				uni.showModal({
					title: '手续费',
					content: '为了限制用户提现次数，每次提现收取2元手续费',
					success: function (res) {
						if (res.confirm) {
							that.$http.post('apply', {price:that.price, type: that.type, img:that.img} ).then(res => {
									return uni.showToast({
										icon:'none',
										title:res.data.msg
									})
									
							}).catch(err => {
							
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		},
	};
</script>

<style lang="scss">
	
	text{
		font-size: 28rpx;
	}
	
	.main{
		background-color: $uni-bg-color-grey;
		height: 100vh;
	}
	
	.page {
		background-color: #f9f9f9;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100vh;
	}
	
	.price{
		height: 100rpx;
		background-color: $uni-bg-color;
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-top: 50rpx;
		
		.title{
			margin-left: 50rpx;
		}
		
		.inp{
			margin-left: 50rpx;
		}
		
	}
	
	.qrcode{
		height: 100rpx;
		background-color: $uni-bg-color;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		margin-top: 50rpx;
		
		.title{
			margin-left: 20rpx;
		}
		
		.inp{
			margin-left: 30rpx;
		}
		
	}
	
	.type{
		margin-top: 50rpx;
		
		.title{
			color: #adacac;
			font-size: 28rpx;
			margin-left: 30rpx;
		}
	}
	
	.radio-type{
		margin-top: 50rpx;
		
		.content{
			padding-top: 0rpx;
			
			.apply-btn{
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: space-between;
				margin-top: 30rpx;
				height: 120rpx;
				background-color: $uni-bg-color;
				padding-left: 30rpx;
				
				.title{
					margin-left: 50rpx;
				}
				
				.btn{
					margin-right: 50rpx;
				}
				
				.img{
					width: 200rpx;
					height: 200rpx;
					
					image{
						width: 100%;
						height: 100%;
					}
				}
			}
		}
	}
	.button {
		margin-top: 100rpx;
		padding: 24rpx 0;
		background-color: #22b14C;
		border-radius: 20rpx;
		width: 626rpx;
		position: fixed;
		bottom: 100rpx;
	
		.text_7 {
			color: #ffffff;
		}
	}
	
	.show-img{
		width: 300rpx;
		height: 300rpx;
		margin: 120rpx auto;
		image{
			width: 100%;
			height: 100%;
		}
	}
</style>